package com.mdinfo.base.utils;

import org.apache.commons.codec.digest.DigestUtils;

/**
 * Created by Administrator on 2017/11/30.
 */
public class Md5Util {

    /**
     * 字符串md5加密
     */
    public static String md5(String str){
        String md5Hex = DigestUtils.md5Hex(str);
        return md5Hex;
    }

    /**
     * 根据原始密码和盐值生成加密密码
     */
    public static String makePwd(String password,String salt){

        String p1 = md5(password) + salt;
        String p2 = md5(p1);
        return p2;
    }

    /**
     * 获取一个随机的盐值
     */
    public static String getSalt(){
        return StringUtil.random6();
    }
}
